﻿using System.Data;

namespace Jayrock.Json.Conversion.Converters
{
    internal sealed class DataTableImporter : ImporterBase
    {
        public DataTableImporter() : base(typeof(DataTable)){}

        //protected override object ImportFromObject(global::Jayrock.Json.Conversion.ImportContext context, global::Jayrock.Json.JsonReader reader)
        //{
        //    if (context == null)
        //        throw new ArgumentNullException("context");

        //    if (reader == null)
        //        throw new ArgumentNullException("reader");

        //    //
        //    // Reader must be sitting on an object.
        //    //

        //    if (reader.TokenClass != JsonTokenClass.Object)
        //        throw new JsonException("Expecting object.");

        //    reader.Read();

        //    //
        //    // Create the NameValueCollection object being deserialized.
        //    // If a hint was supplied, then that's what we will create
        //    // here because it could be that the caller wants to 
        //    // return a subtype of NameValueCollection.
        //    //

        //    DataTable table = new DataTable();

        //    //
        //    // Loop through all members of the object.
        //    //

        //    while (reader.TokenClass != JsonTokenClass.EndObject)
        //    {
        //        string name = reader.ReadMember();

        //        //
        //        // If the value is an array, then it's a multi-value 
        //        // entry otherwise a single-value one.
        //        //

        //        if (reader.TokenClass == JsonTokenClass.Array)
        //        {
        //            reader.Read();

        //            while (reader.TokenClass != JsonTokenClass.EndArray)
        //            {
        //                collection.Add(name, GetValueAsString(reader));
        //                reader.Read();
        //            }
        //        }
        //        else
        //        {
        //            collection.Add(name, GetValueAsString(reader));
        //        }

        //        reader.Read(); // EndArray/String
        //    }

        //    return collection;
        //}
    }
}
